package com.burstly.lib.component.networkcomponent;

import android.content.Context;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import com.burstly.lib.component.IBurstlyAdaptor;
import com.burstly.lib.util.LoggerExt;

public class HierarchyAwareLayout extends FrameLayout
{
  private static final LoggerExt LOG = LoggerExt.getInstance();
  private static final String TAG = HierarchyAwareLayout.class.getSimpleName();
  private View mAdView;
  private final IBurstlyAdaptor mAdaptor;
  private View mDebugView;
  private DebugGestureDetector mGestureDetector;
  private Animation mInAnimation;
  private boolean mIsDebugGestureOn;
  private Animation mOutAnimation;
  private boolean mShowSwipeAnimation = true;
  private View mView;

  public HierarchyAwareLayout(Context paramContext, View paramView, IBurstlyAdaptor paramIBurstlyAdaptor)
  {
    super(paramContext);
    this.mAdaptor = paramIBurstlyAdaptor;
    this.mView = paramView;
    addView(paramView);
  }

  private void initDebugGesture()
  {
    DebugGestureListener localDebugGestureListener = new DebugGestureListener(this);
    this.mGestureDetector = new DebugGestureDetector(getContext(), localDebugGestureListener);
    localDebugGestureListener.setGestureDetector(this.mGestureDetector);
  }

  public void addDebugView(View paramView)
  {
    this.mDebugView = paramView;
    addView(paramView, 0);
  }

  protected FrameLayout.LayoutParams generateDefaultLayoutParams()
  {
    return new FrameLayout.LayoutParams(-2, -2, 17);
  }

  public Animation getInAnimation()
  {
    if (this.mInAnimation == null)
      this.mInAnimation = AnimationUtils.makeInAnimation(getContext(), true);
    return this.mInAnimation;
  }

  public Animation getOutAnimation()
  {
    if (this.mOutAnimation == null)
      this.mOutAnimation = AnimationUtils.makeOutAnimation(getContext(), true);
    return this.mOutAnimation;
  }

  public boolean isShowSwipeAnimation()
  {
    return this.mShowSwipeAnimation;
  }

  protected void onAttachedToWindow()
  {
    super.onAttachedToWindow();
    this.mAdaptor.startViewSession();
  }

  protected void onDetachedFromWindow()
  {
    super.onDetachedFromWindow();
    this.mAdaptor.endViewSession();
  }

  public boolean onInterceptTouchEvent(MotionEvent paramMotionEvent)
  {
    try
    {
      if (!this.mIsDebugGestureOn)
        return super.onInterceptTouchEvent(paramMotionEvent);
      super.onInterceptTouchEvent(paramMotionEvent);
      boolean bool = this.mGestureDetector.onInterceptTouch(paramMotionEvent);
      return bool;
    }
    catch (Exception localException)
    {
      LOG.logWarning(TAG, Log.getStackTraceString(localException), new Object[0]);
    }
    return true;
  }

  public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    try
    {
      boolean bool = super.onKeyDown(paramInt, paramKeyEvent);
      return bool;
    }
    catch (Exception localException)
    {
      LOG.logWarning(TAG, Log.getStackTraceString(localException), new Object[0]);
    }
    return true;
  }

  public boolean onKeyMultiple(int paramInt1, int paramInt2, KeyEvent paramKeyEvent)
  {
    try
    {
      boolean bool = super.onKeyMultiple(paramInt1, paramInt2, paramKeyEvent);
      return bool;
    }
    catch (Exception localException)
    {
      LOG.logWarning(TAG, Log.getStackTraceString(localException), new Object[0]);
    }
    return true;
  }

  public boolean onKeyPreIme(int paramInt, KeyEvent paramKeyEvent)
  {
    try
    {
      boolean bool = super.onKeyPreIme(paramInt, paramKeyEvent);
      return bool;
    }
    catch (Exception localException)
    {
      LOG.logWarning(TAG, Log.getStackTraceString(localException), new Object[0]);
    }
    return true;
  }

  public boolean onKeyShortcut(int paramInt, KeyEvent paramKeyEvent)
  {
    try
    {
      boolean bool = super.onKeyShortcut(paramInt, paramKeyEvent);
      return bool;
    }
    catch (Exception localException)
    {
      LOG.logWarning(TAG, Log.getStackTraceString(localException), new Object[0]);
    }
    return true;
  }

  public boolean onKeyUp(int paramInt, KeyEvent paramKeyEvent)
  {
    try
    {
      boolean bool = super.onKeyUp(paramInt, paramKeyEvent);
      return bool;
    }
    catch (Exception localException)
    {
      LOG.logWarning(TAG, Log.getStackTraceString(localException), new Object[0]);
    }
    return true;
  }

  protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    LoggerExt localLoggerExt = LOG;
    Object[] arrayOfObject = new Object[3];
    arrayOfObject[0] = Integer.valueOf(paramInt3);
    arrayOfObject[1] = Integer.valueOf(paramInt4);
    arrayOfObject[2] = this.mAdaptor;
    localLoggerExt.logDebug("HierarchyAwareLayout", "Adding {2} view (w: {0}, h: {1}) to BurstlyLayout", arrayOfObject);
    super.onLayout(paramBoolean, paramInt1, paramInt2, paramInt3, paramInt4);
  }

  public boolean onTouchEvent(MotionEvent paramMotionEvent)
  {
    boolean bool1;
    try
    {
      LoggerExt localLoggerExt = LOG;
      String str = TAG;
      Object[] arrayOfObject = new Object[1];
      arrayOfObject[0] = Integer.valueOf(paramMotionEvent.getAction());
      localLoggerExt.logDebug(str, "onTouchEvent {0}", arrayOfObject);
      if (!this.mIsDebugGestureOn)
        return super.onTouchEvent(paramMotionEvent);
      if (!this.mGestureDetector.onTouchEvent(paramMotionEvent))
      {
        boolean bool2 = super.onTouchEvent(paramMotionEvent);
        bool1 = false;
        if (!bool2);
      }
      else
      {
        return true;
      }
    }
    catch (Exception localException)
    {
      LOG.logWarning(TAG, Log.getStackTraceString(localException), new Object[0]);
      bool1 = true;
    }
    return bool1;
  }

  public boolean onTrackballEvent(MotionEvent paramMotionEvent)
  {
    try
    {
      boolean bool = super.onTrackballEvent(paramMotionEvent);
      return bool;
    }
    catch (Exception localException)
    {
      LOG.logWarning(TAG, Log.getStackTraceString(localException), new Object[0]);
    }
    return true;
  }

  public void setIsDebugGestureOn(boolean paramBoolean)
  {
    this.mIsDebugGestureOn = paramBoolean;
    if (paramBoolean)
      initDebugGesture();
  }

  public void setShowSwipeAnimation(boolean paramBoolean)
  {
    this.mShowSwipeAnimation = paramBoolean;
  }

  public void setTag(Object paramObject)
  {
    super.setTag(paramObject);
    this.mView.setTag(paramObject);
  }

  public void showAdView()
  {
    if ((this.mAdView != null) && (this.mDebugView != null))
    {
      if (this.mShowSwipeAnimation)
      {
        this.mDebugView.startAnimation(getOutAnimation());
        this.mAdView.startAnimation(getInAnimation());
      }
      this.mAdView.setVisibility(0);
      this.mDebugView.setVisibility(8);
    }
  }

  public void showDebugView()
  {
    int i = getChildCount();
    if (this.mDebugView != null)
    {
      this.mAdView = getChildAt(i - 1);
      if (this.mShowSwipeAnimation)
      {
        this.mAdView.startAnimation(getOutAnimation());
        this.mDebugView.startAnimation(getInAnimation());
      }
      this.mAdView.setVisibility(8);
      this.mDebugView.setVisibility(0);
    }
  }

  public String toString()
  {
    if (this.mDebugView != null)
      return this.mDebugView.toString();
    return super.toString();
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.networkcomponent.HierarchyAwareLayout
 * JD-Core Version:    0.6.2
 */